$(function(){
    $.ajax({
        type: "get",
        url: "/user/queryUser",
        data: {
            page : 1,
            pageSize : 10
        },
        success: function (res) {
            var html = template("userTpl",res);
            $("#user-box").html(html);
        }
    });

    $("#user-box").on("click",".edit-btn",function(){
        var isDelete = Number($(this).attr("data-isDelete"));
        var id = $(this).attr("data-id");
        $.ajax({
            type: "post",
            url: "/user/updateUser",
            data: {
                id : id,
                isDelete : isDelete ? 0 : 1
            },
            success: function (res) {
                if(res.success){
                    location.reload();
                }
            }
        });
    });

});